import 'package:flutterdemo/models/entity/face_detect_entity.dart';

faceDetectEntityFromJson(FaceDetectEntity data, Map<String, dynamic> json) {
	if (json['error_code'] != null) {
		data.errorCode = json['error_code'] is String
				? int.tryParse(json['error_code'])
				: json['error_code'].toInt();
	}
	if (json['error_msg'] != null) {
		data.errorMsg = json['error_msg'].toString();
	}
	if (json['log_id'] != null) {
		data.logId = json['log_id'] is String
				? int.tryParse(json['log_id'])
				: json['log_id'].toInt();
	}
	if (json['timestamp'] != null) {
		data.timestamp = json['timestamp'] is String
				? int.tryParse(json['timestamp'])
				: json['timestamp'].toInt();
	}
	if (json['cached'] != null) {
		data.cached = json['cached'] is String
				? int.tryParse(json['cached'])
				: json['cached'].toInt();
	}
	if (json['result'] != null) {
		data.result = new FaceDetectResult().fromJson(json['result']);
	}
	return data;
}

Map<String, dynamic> faceDetectEntityToJson(FaceDetectEntity entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['error_code'] = entity.errorCode;
	data['error_msg'] = entity.errorMsg;
	data['log_id'] = entity.logId;
	data['timestamp'] = entity.timestamp;
	data['cached'] = entity.cached;
	if (entity.result != null) {
		data['result'] = entity.result.toJson();
	}
	return data;
}

faceDetectResultFromJson(FaceDetectResult data, Map<String, dynamic> json) {
	if (json['face_num'] != null) {
		data.faceNum = json['face_num'] is String
				? int.tryParse(json['face_num'])
				: json['face_num'].toInt();
	}
	if (json['face_list'] != null) {
		data.faceList = new List<FaceDetectResultFaceList>();
		(json['face_list'] as List).forEach((v) {
			data.faceList.add(new FaceDetectResultFaceList().fromJson(v));
		});
	}
	return data;
}

Map<String, dynamic> faceDetectResultToJson(FaceDetectResult entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['face_num'] = entity.faceNum;
	if (entity.faceList != null) {
		data['face_list'] =  entity.faceList.map((v) => v.toJson()).toList();
	}
	return data;
}

faceDetectResultFaceListFromJson(FaceDetectResultFaceList data, Map<String, dynamic> json) {
	if (json['face_token'] != null) {
		data.faceToken = json['face_token'].toString();
	}
	if (json['location'] != null) {
		data.location = new FaceDetectResultFaceListLocation().fromJson(json['location']);
	}
	if (json['face_probability'] != null) {
		data.faceProbability = json['face_probability'] is String
				? int.tryParse(json['face_probability'])
				: json['face_probability'].toInt();
	}
	if (json['angle'] != null) {
		data.angle = new FaceDetectResultFaceListAngle().fromJson(json['angle']);
	}
	if (json['expression'] != null) {
		data.expression = new FaceDetectResultFaceListExpression().fromJson(json['expression']);
	}
	if (json['glasses'] != null) {
		data.glasses = new FaceDetectResultFaceListGlasses().fromJson(json['glasses']);
	}
	if (json['quality'] != null) {
		data.quality = new FaceDetectResultFaceListQuality().fromJson(json['quality']);
	}
	if (json['eye_status'] != null) {
		data.eyeStatus = new FaceDetectResultFaceListEyeStatus().fromJson(json['eye_status']);
	}
	if (json['emotion'] != null) {
		data.emotion = new FaceDetectResultFaceListEmotion().fromJson(json['emotion']);
	}
	if (json['face_type'] != null) {
		data.faceType = new FaceDetectResultFaceListFaceType().fromJson(json['face_type']);
	}
	if (json['gender'] != null) {
		data.gender = new FaceDetectResultFaceListGender().fromJson(json['gender']);
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListToJson(FaceDetectResultFaceList entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['face_token'] = entity.faceToken;
	if (entity.location != null) {
		data['location'] = entity.location.toJson();
	}
	data['face_probability'] = entity.faceProbability;
	if (entity.angle != null) {
		data['angle'] = entity.angle.toJson();
	}
	if (entity.expression != null) {
		data['expression'] = entity.expression.toJson();
	}
	if (entity.glasses != null) {
		data['glasses'] = entity.glasses.toJson();
	}
	if (entity.quality != null) {
		data['quality'] = entity.quality.toJson();
	}
	if (entity.eyeStatus != null) {
		data['eye_status'] = entity.eyeStatus.toJson();
	}
	if (entity.emotion != null) {
		data['emotion'] = entity.emotion.toJson();
	}
	if (entity.faceType != null) {
		data['face_type'] = entity.faceType.toJson();
	}
	if (entity.gender != null) {
		data['gender'] = entity.gender.toJson();
	}
	return data;
}

faceDetectResultFaceListLocationFromJson(FaceDetectResultFaceListLocation data, Map<String, dynamic> json) {
	if (json['left'] != null) {
		data.left = json['left'] is String
				? double.tryParse(json['left'])
				: json['left'].toDouble();
	}
	if (json['top'] != null) {
		data.top = json['top'] is String
				? double.tryParse(json['top'])
				: json['top'].toDouble();
	}
	if (json['width'] != null) {
		data.width = json['width'] is String
				? int.tryParse(json['width'])
				: json['width'].toInt();
	}
	if (json['height'] != null) {
		data.height = json['height'] is String
				? int.tryParse(json['height'])
				: json['height'].toInt();
	}
	if (json['rotation'] != null) {
		data.rotation = json['rotation'] is String
				? int.tryParse(json['rotation'])
				: json['rotation'].toInt();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListLocationToJson(FaceDetectResultFaceListLocation entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['left'] = entity.left;
	data['top'] = entity.top;
	data['width'] = entity.width;
	data['height'] = entity.height;
	data['rotation'] = entity.rotation;
	return data;
}

faceDetectResultFaceListAngleFromJson(FaceDetectResultFaceListAngle data, Map<String, dynamic> json) {
	if (json['yaw'] != null) {
		data.yaw = json['yaw'] is String
				? double.tryParse(json['yaw'])
				: json['yaw'].toDouble();
	}
	if (json['pitch'] != null) {
		data.pitch = json['pitch'] is String
				? double.tryParse(json['pitch'])
				: json['pitch'].toDouble();
	}
	if (json['roll'] != null) {
		data.roll = json['roll'] is String
				? double.tryParse(json['roll'])
				: json['roll'].toDouble();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListAngleToJson(FaceDetectResultFaceListAngle entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['yaw'] = entity.yaw;
	data['pitch'] = entity.pitch;
	data['roll'] = entity.roll;
	return data;
}

faceDetectResultFaceListExpressionFromJson(FaceDetectResultFaceListExpression data, Map<String, dynamic> json) {
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['probability'] != null) {
		data.probability = json['probability'] is String
				? int.tryParse(json['probability'])
				: json['probability'].toInt();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListExpressionToJson(FaceDetectResultFaceListExpression entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['type'] = entity.type;
	data['probability'] = entity.probability;
	return data;
}

faceDetectResultFaceListGlassesFromJson(FaceDetectResultFaceListGlasses data, Map<String, dynamic> json) {
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['probability'] != null) {
		data.probability = json['probability'] is String
				? int.tryParse(json['probability'])
				: json['probability'].toInt();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListGlassesToJson(FaceDetectResultFaceListGlasses entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['type'] = entity.type;
	data['probability'] = entity.probability;
	return data;
}

faceDetectResultFaceListQualityFromJson(FaceDetectResultFaceListQuality data, Map<String, dynamic> json) {
	if (json['occlusion'] != null) {
		data.occlusion = new FaceDetectResultFaceListQualityOcclusion().fromJson(json['occlusion']);
	}
	if (json['blur'] != null) {
		data.blur = json['blur'] is String
				? int.tryParse(json['blur'])
				: json['blur'].toInt();
	}
	if (json['illumination'] != null) {
		data.illumination = json['illumination'] is String
				? int.tryParse(json['illumination'])
				: json['illumination'].toInt();
	}
	if (json['completeness'] != null) {
		data.completeness = json['completeness'] is String
				? int.tryParse(json['completeness'])
				: json['completeness'].toInt();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListQualityToJson(FaceDetectResultFaceListQuality entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	if (entity.occlusion != null) {
		data['occlusion'] = entity.occlusion.toJson();
	}
	data['blur'] = entity.blur;
	data['illumination'] = entity.illumination;
	data['completeness'] = entity.completeness;
	return data;
}

faceDetectResultFaceListQualityOcclusionFromJson(FaceDetectResultFaceListQualityOcclusion data, Map<String, dynamic> json) {
	if (json['left_eye'] != null) {
		data.leftEye = json['left_eye'] is String
				? double.tryParse(json['left_eye'])
				: json['left_eye'].toDouble();
	}
	if (json['right_eye'] != null) {
		data.rightEye = json['right_eye'] is String
				? double.tryParse(json['right_eye'])
				: json['right_eye'].toDouble();
	}
	if (json['nose'] != null) {
		data.nose = json['nose'] is String
				? int.tryParse(json['nose'])
				: json['nose'].toInt();
	}
	if (json['mouth'] != null) {
		data.mouth = json['mouth'] is String
				? int.tryParse(json['mouth'])
				: json['mouth'].toInt();
	}
	if (json['left_cheek'] != null) {
		data.leftCheek = json['left_cheek'] is String
				? double.tryParse(json['left_cheek'])
				: json['left_cheek'].toDouble();
	}
	if (json['right_cheek'] != null) {
		data.rightCheek = json['right_cheek'] is String
				? double.tryParse(json['right_cheek'])
				: json['right_cheek'].toDouble();
	}
	if (json['chin_contour'] != null) {
		data.chinContour = json['chin_contour'] is String
				? int.tryParse(json['chin_contour'])
				: json['chin_contour'].toInt();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListQualityOcclusionToJson(FaceDetectResultFaceListQualityOcclusion entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['left_eye'] = entity.leftEye;
	data['right_eye'] = entity.rightEye;
	data['nose'] = entity.nose;
	data['mouth'] = entity.mouth;
	data['left_cheek'] = entity.leftCheek;
	data['right_cheek'] = entity.rightCheek;
	data['chin_contour'] = entity.chinContour;
	return data;
}

faceDetectResultFaceListEyeStatusFromJson(FaceDetectResultFaceListEyeStatus data, Map<String, dynamic> json) {
	if (json['left_eye'] != null) {
		data.leftEye = json['left_eye'] is String
				? int.tryParse(json['left_eye'])
				: json['left_eye'].toInt();
	}
	if (json['right_eye'] != null) {
		data.rightEye = json['right_eye'] is String
				? int.tryParse(json['right_eye'])
				: json['right_eye'].toInt();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListEyeStatusToJson(FaceDetectResultFaceListEyeStatus entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['left_eye'] = entity.leftEye;
	data['right_eye'] = entity.rightEye;
	return data;
}

faceDetectResultFaceListEmotionFromJson(FaceDetectResultFaceListEmotion data, Map<String, dynamic> json) {
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['probability'] != null) {
		data.probability = json['probability'] is String
				? double.tryParse(json['probability'])
				: json['probability'].toDouble();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListEmotionToJson(FaceDetectResultFaceListEmotion entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['type'] = entity.type;
	data['probability'] = entity.probability;
	return data;
}

faceDetectResultFaceListFaceTypeFromJson(FaceDetectResultFaceListFaceType data, Map<String, dynamic> json) {
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['probability'] != null) {
		data.probability = json['probability'] is String
				? double.tryParse(json['probability'])
				: json['probability'].toDouble();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListFaceTypeToJson(FaceDetectResultFaceListFaceType entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['type'] = entity.type;
	data['probability'] = entity.probability;
	return data;
}

faceDetectResultFaceListGenderFromJson(FaceDetectResultFaceListGender data, Map<String, dynamic> json) {
	if (json['type'] != null) {
		data.type = json['type'].toString();
	}
	if (json['probability'] != null) {
		data.probability = json['probability'] is String
				? int.tryParse(json['probability'])
				: json['probability'].toInt();
	}
	return data;
}

Map<String, dynamic> faceDetectResultFaceListGenderToJson(FaceDetectResultFaceListGender entity) {
	final Map<String, dynamic> data = new Map<String, dynamic>();
	data['type'] = entity.type;
	data['probability'] = entity.probability;
	return data;
}